﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace ArgusLib.Fractals.OrbitFractals
{
	public class DataSetComplex : DataSet<Complex>
	{
		public DataSetComplex(Parameter parameter)
			: base(parameter)
		{
		}

		public override Complex Convert(int x, int y)
		{
			double x2 = x - this.CalculationParameter.PixelWidth / 2;
			double y2 = this.CalculationParameter.PixelHeight / 2 - y;
			double re = x2 * this.CalculationParameter.ShownArea.Width / this.CalculationParameter.PixelWidth;
			double im = y2 * this.CalculationParameter.ShownArea.Height / this.CalculationParameter.PixelHeight;
			Complex rot = Complex.FromPolarCoordinates(1, this.CalculationParameter.ShownArea.Rotation);
			Complex c = new Complex(re, im);
			return c * rot + this.CalculationParameter.ShownArea.Center;
		}
	}
}
